package com.cctv.order.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 接收mq消息
 *
 * @Author: cctv
 * @Date: 2019/6/11 10:48
 */
@Slf4j
@Component
public class MqReceiver {
    //   1.手动创建队列 @RabbitListener(queues = "myQueue")
//   2.自动创建队列 @RabbitListener(queuesToDeclare = @Queue("myQueue"))
//    3.自动创建并bing exchange
    @RabbitListener(bindings = @QueueBinding(value = @Queue("myQueue"), exchange = @Exchange("myExchange")))
    public void process(String message) {
        log.info("MqReceiver:{}", message);
    }
    @RabbitListener(bindings = @QueueBinding(value = @Queue("fruitQueue"),key = "fruit",exchange = @Exchange("myOrder")))
    public void processFruit(String message) {
        log.info("fruit MqReceiver:{}", message);
    }
    @RabbitListener(bindings = @QueueBinding(value = @Queue("computerQueue"),key = "computer", exchange = @Exchange("myOrder")))
    public void processComputer(String message) {
        log.info("computer MqReceiver:{}", message);
    }

}
